package functional

import introduction.functions.sum

/**
 *@author LikeYouDo
 *@date 2024/12/11 08:42
 */
fun calculate(x: Int, y: Int, operation: (Int, Int) -> Int): Int {
    return operation(x, y)
}

fun square(x: Int) = x * x

fun operation(): (Int) -> Int {
    return ::square
}

fun main() {
    val sumResult = calculate(4, 5, ::sum)
    val mulResult = calculate(4, 5) { a, b -> a * b }
    println("sumResult $sumResult, mulResult $mulResult")

    val  func = operation()
    println(func(5))
}